package com.ehotting.mqbd.loader.config;

import com.ehotting.eaf.redis.service.RedisService;
import com.ehotting.mqbd.core.manager.*;
import com.ehotting.mqbd.loader.task.SolverCountLoader;
import com.ehotting.mqbd.loader.task.SolverInfoLoader;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.EnableScheduling;

@Configuration
@EnableScheduling
@Order(4)
public class LoaderConfig {

    @DependsOn(value="solverAllocator")
    @Bean
    public SolverInfoLoader ServerLoader(SolverInfoManager solverInfoManager, ModuleManager moduleManager, RedisService redisService){
        SolverInfoLoader solverInfoLoader =  new SolverInfoLoader();
        solverInfoLoader.setSolverInfoManager(solverInfoManager);
        solverInfoLoader.setModuleManager(moduleManager);
        solverInfoLoader.setRedisService(redisService);
        return solverInfoLoader;
    }

    @DependsOn(value="solverAllocator")
    @Bean
    public SolverCountLoader serverCountLoader(SolverCountManager solverCountManager,
                                               SolverStateManager solverStateManager,
                                               MqQueueManager mqQueueManager,
                                               RedisService redisService,
                                               ConsumerNodeManager consumerNodeManager,
                                               ModuleManager moduleManager,
                                               SolverInfoManager solverInfoManager){
        SolverCountLoader SolverCountLoader =  new SolverCountLoader(
                solverCountManager,
                solverStateManager,
                mqQueueManager,
                redisService,
                consumerNodeManager,
                moduleManager,
                solverInfoManager);
        return SolverCountLoader;
    }

}